<template>
	<view class="page">
		<view class="sever-list">
			<view class="server-item" v-for="(item, index) in list" :key="index" @click="link(item)">
				<view class="search-info">
					<image mode="aspectFill" class="image" :src="item.imageUrl || '/static/images/ic_logo.png'"></image>
					<view>
						<view class="top-title">{{item.title || ''}}</view>
						<view class="bottom-title">{{item.subtitle || ''}}</view>
					</view>
				</view>
				<view class="btn">查看</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getBanner
	} from '@/apis/request.js'

	export default {
		data() {
			return {
				list: []
			};
		},
		onLoad() {
			this.init();
		},
		methods: {
			init() {
				getBanner({
					position: 3
				}).then(res => {
					this.list = res;
				})
			},
			link(item) {
				if (item.type == 2 && item.jumpPath) {
					uni.navigateToMiniProgram({
						shortLink: item.jumpPath
					});
				} else if (item.type == 1 && item.jumpPath) {
					if (item.jumpPath.indexOf('http') == 0) {
						this.to('/pages/other/webView/main?path=' + encodeURIComponent(item.jumpPath));
					} else {
						this.to(item.jumpPath);
					}
				}
			}
		}
	};
</script>

<style scoped lang="scss">
	.page {
		height: 100%;
		min-height: 100vh;
		background-color: #f2f2f2;

		.sever-list {
			background-color: #fff;

			.server-item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 30rpx;
				border-bottom: 2rpx solid #efefef;

				.search-info {
					display: flex;
					align-items: center;

					.image {
						flex-shrink: 0;
						width: 120rpx;
						height: 120rpx;
						margin-right: 20rpx;
						border-radius: 50%;
					}

					.top-title {
						font-size: 30rpx;
					}

					.bottom-title {
						font-size: 24rpx;
						color: #666666;
						margin-top: 10rpx;
					}
				}

				.btn {
					width: 100rpx;
					height: 50rpx;
					border-radius: 28rpx;
					border: 2rpx solid #32C59A;
					line-height: 50rpx;
					text-align: center;
					color: #32C59A;
					font-size: 24rpx;
				}
			}
		}
	}
</style>